-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Python2 String Handling Cleanup in parsers.pyx #26270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -671,11 +664,10 @@ cdef class TextReader: | |||
|
|||
self.handle = source | |||
|
|||
if isinstance(source, basestring): | |||
if not isinstance(source, bytes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get to this point in Py3 the object would have to be a str in the first place, which means it logically isn't a bytes type hence why I removed this condition altogether
@@ -21,16 +21,14 @@ from cython import Py_ssize_t | |||
from cpython cimport (PyObject, PyBytes_FromString, | |||
PyBytes_AsString, | |||
PyUnicode_AsUTF8String, | |||
PyErr_Occurred, PyErr_Fetch) | |||
PyErr_Occurred, PyErr_Fetch, | |||
PyUnicode_Decode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was orthogonal but figured preferable to import this way rather than through Python header (cython doesn't expose the last remaining item coming from Python.h)
@@ -768,9 +760,7 @@ cdef class TextReader: | |||
for i in range(field_count): | |||
word = self.parser.words[start + i] | |||
|
|||
if path == CSTRING: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSTRING was not a possible value in this enum hence removal. See here:
pandas/pandas/_libs/parsers.pyx
Line 1430 in 0989339
cdef inline StringPath _string_path(char *encoding): |
Codecov Report
@@ Coverage Diff @@
## master #26270 +/- ##
==========================================
- Coverage 91.99% 91.98% -0.01%
==========================================
Files 175 175
Lines 52379 52379
==========================================
- Hits 48184 48180 -4
- Misses 4195 4199 +4
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #26270 +/- ##
==========================================
- Coverage 91.99% 91.98% -0.01%
==========================================
Files 175 175
Lines 52379 52379
==========================================
- Hits 48184 48180 -4
- Misses 4195 4199 +4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
thanks @WillAyd |
Just removing some old Py2 cruft hanging around in parsers.pyx